FROM curlimages/curl AS curl
RUN mkdir -p /home/curl_user/jars && \
    curl -L https://repo.huaweicloud.com/repository/maven/huaweicloudsdk/com/huaweicloud/obs/hadoop-huaweicloud/3.1.1-hw-53.7/hadoop-huaweicloud-3.1.1-hw-53.7.jar --output /home/curl_user/jars/hadoop-huaweicloud-3.1.1-hw-53.7.jar

FROM apache/hive:3.1.3

USER root
RUN mkdir -p /home/hive/ && \
    chown -R hive:hive /home/hive/
ADD --chown=hive:hive --chmod=644 https://maven.aliyun.com/repository/central/com/mysql/mysql-connector-j/8.0.33/mysql-connector-j-8.0.33.jar /opt/hive/lib/mysql-connector-j-8.0.33.jar
ADD --chown=hive:hive --chmod=644 https://repo.maven.apache.org/maven2/org/apache/paimon/paimon-hive-connector-3.1/0.5.0-incubating/paimon-hive-connector-3.1-0.5.0-incubating.jar /opt/hive/lib/paimon-hive-connector-3.1-0.5.0-incubating.jar
ADD --chown=hive:hive --chmod=664 https://repo.maven.apache.org/maven2/org/apache/paimon/paimon-s3/0.5.0-incubating/paimon-s3-0.5.0-incubating.jar /opt/hive/lib/paimon-s3-0.5.0-incubating.jar

COPY --from=curl --chown=hive:hive --chmod=644 /home/curl_user/jars/*.jar /opt/hadoop/share/hadoop/tools/lib/

USER hive